<?php

@include_once("connect.php");

$res = [];
$tell = $_POST["tellnumber"];
$pwd = $_POST["password"];
if ($tell && $pwd) {
  $sql = "SELECT * FROM user WHERE tellnumber='$tell'";
  $gettab = mysqli_query($con, $sql);
  $arr = mysqli_fetch_array($gettab);
  if ($arr) {
    $res["status"] = false;
    $res["mag"] = "已被注册";
  } else {
    $sql = "INSERT INTO user (tellnumber,password) VALUES ('$tell','$pwd')";
    $a = mysqli_query($con, $sql);
    if ($a > 0) {
      $res["status"] = true;
      $res["mag"] = "注册成功";
    } else {
      $res["status"] = false;
      $res["mag"] = "数据库错误";
    }
  }
} else {
  $res["status"] = false;
  $res["mag"] = "前端数据有误";
}

echo (json_encode($res, JSON_UNESCAPED_UNICODE));
